using Digitalmes.Domain.Entities.Mes.Equipments;

namespace Digitalmes.Application.Mes.Equipments.Alarms.Commands;

/// <summary>
/// 警报定义项删除命令。
/// </summary>
public sealed record DeleteAlarmItemCommand(long Id) : IRequest<IResult<bool>>;

internal sealed class DeleteAlarmItemCommandHandler(IRepository<EquipAlarmItem> repo) : IRequestHandler<DeleteAlarmItemCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteAlarmItemCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.Id, cancellationToken);
        return Result.From(ok);
    }
}
